package com.hd.trans.files.fragment;

import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.ViewStub;
import android.widget.TextView;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.fragment.app.Fragment;

import com.hd.trans.R;


abstract public class BaseFragment extends Fragment {

    protected View mRootView;

    public abstract int getLayoutId();

    private ViewStub mEmptyViewStub;
    private TextView mEmptyHintText;

    @Nullable
    @Override
    public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        mRootView = inflater.inflate(getLayoutId(), container);
        return mRootView;
    }

    protected ViewStub getEmptyView() {
        if (mEmptyViewStub == null) {
            mEmptyViewStub = mRootView.findViewById(R.id.list_empty_view_container);
            View emptyView = mEmptyViewStub.inflate();
//            mEmptyHintText = emptyView.findViewById(R.id.list_empty_text);
        }
        return mEmptyViewStub;
    }

    protected void setEmptyViewVisibility(int visibility) {
        getEmptyView().setVisibility(visibility);
    }

    protected void setEmptyHintText(String text) {
        mEmptyHintText.setText(text);
    }
}
